// votePage/pages/index/index.js
import { wxLogin } from '../../../utils/utils'
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list:'',
    loading:false
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    // this.getList();
    wxLogin();
  },

 // 活动列表
 getList: function () {
  wx.showLoading({
      title: '加载中',
  })
  this.setData({
      loading:false
  })
  var _this = this;
  wx.request({
      url: app.globalData.baseNew + 'api/activity',
      method:'get',
      success(res) {
          wx.hideLoading()
          _this.setData({
              loading:false
          })
          if (res.statusCode == 200) {
            console.log(res.data.data)
              _this.setData({
                list: [...res.data.data]
              })
          } else {
              wx.showToast({
                  title: res.data.message,
                  icon: 'none',
                  duration: 2000
              })
          }
      },
      fail(err) {
         console.log(err)
      }
  })
},

onShareAppMessage: function () {
  return {
    title: '书香长江投票活动',
    path: '/votePage/pages/index/index'
  }
},

onShareTimeline: function () {
  return {
    title: '书香长江投票活动',
    path: '/votePage/pages/index/index'
  }
},

goList:function(e) {
  var { id } = e.currentTarget.dataset;
  console.log(id);
  wx.navigateTo({
     url: '/votePage/pages/list/list?id=' + id,
  })
 }
})